package com.src.myapplication.ui.view;

import android.graphics.Color;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.View;

import com.src.myapplication.R;
import com.src.myapplication.base.BaseFragment;
import com.src.myapplication.ui.adapter.PengYouVAdapter;
import com.src.myapplication.utils.FragmentFactory_PengYou;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/10/17.
 */
public class FragmentPengYou extends BaseFragment {
    public TabLayout tb;
    public ViewPager vp;




    @Override
    public void initView(View view) {
        tb = (TabLayout) view.findViewById(R.id.tb_pen);
        vp = (ViewPager) view.findViewById(R.id.vp_pen);

        tb.setSelectedTabIndicatorColor(Color.parseColor("#EE554D"));
        //设置指示器高度
        //导航模式
        String[] stringArray = getResources().getStringArray(R.array.pengyou_title);

        List<Fragment> data = new ArrayList<>();
        for (int i = 0; i < stringArray.length; i++) {
            Fragment fragment = FragmentFactory_PengYou.createFragment_pengyou(i);
            data.add(fragment);
        }
        PengYouVAdapter adapter = new PengYouVAdapter(getFragmentManager(), stringArray, data);
        vp.setOffscreenPageLimit(2);
        tb.setupWithViewPager(vp);
        vp.setAdapter(adapter);

    }


    @Override
    public int getLayoutId() {
        return R.layout.fragment_pengyou;
    }
}